﻿using BluetoothMachine.ExpandHelper;
using BluetoothMachine.Lucifer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BluetoothMachine.Protocols
{
    public class QuiescentCurrentModbus : IProtocol
    {
        private byte _addr;
        public QuiescentCurrentModbus(byte addr)
        {
            _addr = addr;
        }

        public byte[] GetStream()
        {
            List<byte> list = new List<byte>();
            list.Add(_addr);//设备地址
            list.Add(0x03);//0x03功能码====查询从设备寄存器内容
            list.Add(0x00);
            list.Add(0x04);//寄存器起始地址
            list.Add(0x00);
            list.Add(0x04);//寄存器个数
            byte[] crc = BitConverter.GetBytes(CMBRTU.CalculateCrc(list.ToArray(), list.Count));
            list.AddRange(crc);
            return list.ToArray();
        }
    }
}
